package com.sf.webside.dao;

import com.sf.webside.entity.CmsArticleEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

/**
 * Created by tanjing on 2019/2/21.
 */
@Repository
public interface CmsActicleDao extends JpaRepository<CmsArticleEntity,String>,JpaSpecificationExecutor<CmsArticleEntity>{
    /**
     * 根据栏目+语言查询文章-分页
     * @param categoryId
     * @param delFlag
     * @param pageable
     * @return
     */
    Page<CmsArticleEntity> findByCategoryIdAndLanguageTypeAndDelFlagOrderByIssueDateDesc(String categoryId, String languageType,String delFlag, Pageable pageable);
    /**
     * 根据语言查询文章-分页
     * @param delFlag
     * @param pageable
     * @return
     */
    Page<CmsArticleEntity> findByLanguageTypeAndDelFlagOrderByIssueDateDesc(String languageType, String delFlag, Pageable pageable);
    /**
     * 根据语言查询文章-分页
     * @param delFlag
     * @param pageable
     * @return
     */
    Page<CmsArticleEntity> findByCategoryIdAndDelFlagOrderByIssueDateDesc(String categoryId, String delFlag, Pageable pageable);
    /**
     * 根据全部文章-分页
     * @param delFlag
     * @param pageable
     * @return
     */
    Page<CmsArticleEntity> findByDelFlagOrderByIssueDateDesc(String delFlag, Pageable pageable);
    /**
     * 根据id查询文章
     * @param id
     * @return
     */
    CmsArticleEntity findByIdAndDelFlag(String id,String delFlag);
}
